{% extends "common/layout.html" %}
{% block content %}
    <div class="row">


    </div>

    <div class="row">


        <div class="col-sm-10 col-sm-offset-1">

            <div class="row time-pick">

                <div class='col-sm-2 col-sm-offset-6'>
                    <div class="form-group">
                        <label>选择开始时间：</label>
                        <!--指定 date标记-->
                        <div class='input-group date' id='datetimepickers'>
                            <input type='text' class="form-control" name="starttime" id="starttime"
                                   value="{{ stime }}"/>
                            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
                        </div>
                    </div>
                </div>


                <div class='col-sm-2'>
                    <div class="form-group">
                        <label>选择结束时间：</label>
                        <!--指定 date标记-->
                        <div class='input-group date' id='datetimepickere'>
                            <input type='text' class="form-control" name="endtime" id="endtime" value="{{ etime }}"/>
                            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
                        </div>
                    </div>
                </div>


                <div class='col-sm-1'>
                    <div class="form-group">
                        <label></label>
                        <button type="submit" class="btn btn-primary btn-sm btn-block do-pickup " id="dopicker">
                            搜索
                        </button>
                    </div>
                    <script type="text/javascript">
                        {#搜索#}
                        var donepicker = {
                            init: function () {
                                this.eventBind()
                            },
                            eventBind: function () {
                                $(".do-pickup").click(function () {
                                    var starttime = $(".time-pick input[name=starttime]").val();
                                    var endtime = $(".time-pick input[name=endtime]").val();
                                    var urlindex = common_ops.buildUrl("/record/recordsearch?starttime=") + starttime + "&endtime=" + endtime;
                                    document.location.href = urlindex;

                                });
                            }
                        };
                        $(document).ready(function () {
                            donepicker.init();
                        });
                        {#日期#}
                        var mydata = new Date();
                        var lastM = new Date(new Date().setMonth(new Date().getMonth() - 1));
                        {#var mudata2 = mydata.setMonth(mydata.getMonth() - 1)#}
                        $(function () {
                            var picker1 = $('#datetimepickers').datetimepicker({
                                format: 'YYYY-MM-DD',
                                locale: moment.locale('zh-cn'),
                                defaultDate: lastM.toLocaleDateString()
                                //minDate: '2016-7-1'
                            });
                            var picker2 = $('#datetimepickere').datetimepicker({
                                format: 'YYYY-MM-DD',
                                locale: moment.locale('zh-cn'),
                                defaultDate: mydata.toLocaleDateString()
                            });
                            //动态设置最小值
                            picker1.on('dp.change', function (e) {
                                picker2.data('DateTimePicker').minDate(e.date);
                            });
                            //动态设置最大值
                            picker2.on('dp.change', function (e) {
                                picker1.data('DateTimePicker').maxDate(e.date);
                            });
                        });
                    </script>
                </div>


                <div class='col-sm-1'>
                    <div class="form-group">
                        <label></label>
                        <button type="submit" class="btn btn-success btn-sm btn-block do-export " id="doexport">
                            导出
                        </button>
                    </div>

                    <script type="text/javascript">
                        var exporter = {
                            init: function () {
                                this.eventBind()
                            },
                            eventBind: function () {
                                $(".do-export").click(function () {
                                    var starttime = $(".time-pick input[name=starttime]").val();
                                    var endtime = $(".time-pick input[name=endtime]").val();
                                    var urlindex = common_ops.buildUrl("/seal/export?starttime=") + starttime + "&endtime=" + endtime;
                                    document.location.href = urlindex;

                                });
                            }
                        };
                        $(document).ready(function () {
                            exporter.init();
                        });
                    </script>
                </div>


            </div>


            <row class="data-table">
                <table class="table table-bordered table-hover">
                    <tr>
                        <th class="info">记录编号</th>
                        <th class="info">操作模块</th>
                        <th class="info">操作项目/承建商</th>
                        <th class="info">操作动作</th>
                        <th class="info">文件名称</th>
                        <th class="info">操作人</th>
                        <th class="info">操作公司</th>
                        <th class="info">操作时间</th>
                    </tr>
                    {% for item in record %}
                        <tr>
                            <th>{{ item.id }}</th>
                            <th>{{ item.classone }}</th>
                            <th>{{ item.project }}</th>
                            <th>{{ item.action }}</th>
                            <th>{{ item.filename }}</th>
                            <th>{{ item.creater.nickname }}</th>
                            <th>{{ item.creater.company }}</th>
                            <th>{{ item.time }}</th>
                        </tr>

                    {% endfor %}
                </table>
            </row>

            <div>
                {% include "common/pagenation.html" %}
            </div>

        </div>
    </div>



{% endblock %}


{% block js %}
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
{% endblock %}


